﻿CREATE PROCEDURE UpdateCargo(
		@CargoName nvarchar(100),
        @Description nvarchar(250),
        @Code nchar(5),
        @CodeETSNG nchar(6),
        @CargoETSNGName nvarchar(250),
        @CodeGNG nchar(8),
        @CodeGNGName nvarchar(250),
        @Mnemocode nvarchar(12) )
AS
BEGIN 
	UPDATE Cargo
	SET 
		cargo.[Description] = @Description,
		cargo.ShortCode = @Code,
		cargo.Code = @CodeETSNG,
		cargo.CodeGNG = @CodeGNG,
		cargo.Mnemocode = @Mnemocode
	FROM
		dbo.Cargo AS cargo
	WHERE
		cargo.Name = @CargoName


	UPDATE CargoETSNG 
	SET 
		cargoETSNG.Name = @CodeGNGName
	FROM
		dbo.Cargo AS cargo
		inner join CargoETSNG AS cargoETSNG ON cargo.Code = cargoETSNG.CargoETSNG_ID
	WHERE 
		cargo.Name = @CargoName

	UPDATE CargoGNG
	SET 
		cargoGNG.Name = @CodeGNGName
	FROM
		dbo.Cargo AS cargo
		inner join CargoGNG AS cargoGNG ON cargo.CodeGNG = cargoGNG.CargoGNG_ID
	WHERE 
		cargo.Name = @CargoName
END